package hzjbbis.framework.value.oracle;

import hzjbbis.framework.value.PreparedStatementValue;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import oracle.sql.ARRAY;
import oracle.sql.ArrayDescriptor;

public class CharTab implements PreparedStatementValue {
	private List paramsList = new ArrayList();

	public String getOracleTypeName() {
		return "TYPE_CHARTAB";
	}

	public void prepareParameter(PreparedStatement ps, int parameterIndex)
			throws SQLException {
		ps.setObject(parameterIndex, getOracleTypeArray(getOracleTypeName(), ps
				.getConnection()));
	}

	public void addCharString(String charStr) {
		paramsList.add(charStr);
	}

	private ARRAY getOracleTypeArray(String typeName, Connection conn)
			throws SQLException {
		return new ARRAY(ArrayDescriptor.createDescriptor(typeName, conn),
				conn, paramsList.toArray());
	}
}
